<!DOCTYPE html>
<html>
<head>
    <title>站内信</title>
    <include file='public/head'></include>
    <link rel="stylesheet" href="__STATIC__/js/element/css/element.css">
    <style>
        [v-cloak] {
            display: none !important;
        }

        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 178px;
            height: 178px;
            line-height: 178px;
            text-align: center;
        }
        .avatar {
            width: 178px;
            height: 178px;
            display: block;
        }
        .layui-legend-size {
            font-size: 14px !important;
        }

        .layui-nopadding {
            padding: 0 !important;
        }

        .layui-overflow {
            overflow: auto;
        }

        .layui-nomargin {
            margin: 0 !important;
        }

        .layui-bottom {
            border-bottom: 1px solid rgb(226, 226, 226);
        }

        .layui-input {
            height: 30px !important;
        }

        .layui-form-search-item .layui-inline {
            margin-bottom: 5px;
        }

        .layui-form-search-item label {
            margin-left: 15px;
        }

        .layui-table-page {
            padding: 7px 0px 0px;
        }

        .layui-field-padding {
            border-width: 1px;
            padding: 0 0 5px 10px;
        }

        .mytable {
            table-layout: fixed;
        }

        .mytable tr td {
            text-overflow: ellipsis;
            -moz-text-overflow: ellipsis; /* for Firefox,mozilla */
            overflow: hidden;
            white-space: nowrap;
            text-align: left
        }
    </style>
</head>
<body>
<!-- layui-tab开始 -->
<div class="layui-tab" id="app" v-cloak>
    <!-- 顶部导航菜单开始 -->
    <div class="layui-tab-nav">
        <ul class="layui-tab-title">
            {:getNav('com_message','admin_index/index')};
        </ul>
    </div>
    <!-- 顶部导航菜单结束 -->
    <br>

    <!-- 内容开始 -->
    <div class="layui-card">

        <!-- 搜索栏开始 -->
<!--        <fieldset class="layui-elem-field layui-field-title layui-field-padding">-->
<!--            <legend class="layui-legend-size">搜索</legend>-->
<!--            <div class="layui-form-search-item">-->

<!--                <div class="layui-inline">-->

<!--                    <label>标题</label>-->
<!--                    <div class="layui-inline">-->
<!--                        <div class="layui-input-inline" style="width:120px;">-->
<!--                            <input type="text" class="layui-input" id="test2" name="mobile" value="">-->
<!--                        </div>-->
<!--                    </div>-->

<!--                    <label>状态</label>-->
<!--                    <div class="layui-input-inline" style="width: 150px;">-->
<!--                        <select name="status" class="layui-input" lay-verify="" lay-search="">-->
<!--                            <option value="">全部</option>-->
<!--                            <option value="1">正常</option>-->
<!--                            <option value="2">禁用</option>-->

<!--                        </select>-->
<!--                    </div>-->
<!--                </div>-->

<!--                <div class="layui-inline">-->
<!--                    <button type="submit" class="layui-btn layui-btn-sm layui-btn-primary " style="font-weight:800;"-->
<!--                            lay-submit="" lay-filter="demo2"><i class="layui-icon ">&#xe615;</i>搜索-->
<!--                    </button>-->
<!--                </div>-->

<!--            </div>-->
<!--        </fieldset>-->
        <!-- 搜索栏结束 -->


        <!-- 表头按钮开始 -->
        <div class="layui-card-header layui-bg-gray layui-bottom ">
            <el-button type="primary" size="mini" @click="openAdd">添加</el-button>
            <!--        <a href="javascript:;" class="layui-btn layui-btn-xs layui-bg-red delete-btn" >-->
            <!--            <i class="layui-icon">&#xe640;</i>批量删除-->
            <!--        </a>-->
        </div>
        <!-- 表头按钮结束 -->

        <!-- 数据表格开始 -->
        <table class="layui-table layui-nomargin mytable">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>发布人</th>
                            <th>站内信标题</th>
                            <th>发布时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <volist  name="list" id="vo">
                            <tr lay-fliter="test3">
                                <td>{$vo.id}</td>
                                <td>{$vo.username}</td>
                                <td>{$vo.title}</td>
                                <td>{$vo.time}</td>
                                <td>
                                    <button type="button" @click="openEdit({$vo.id})"class="layui-btn layui-btn-primary layui-btn-xs" title="编辑"><i class="layui-icon">&#xe642;</i></button>
                                    <button type='button' class='layui-btn layui-btn-xs layui-btn-primary delete-btn' style='font-weight:800 ;' data-id='{$vo.id}' title='删除'><i class='layui-icon'>&#xe640;</i></button>
                                </td>
                            </tr>
                        </volist>
                    </tbody>
                </table>


            <!--分页开始-->
            <div class="layui-table-page">
                <div id="layui-table-page1">
                    <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
                        {$page|default=''}
                    </div>
                </div>
            </div>
        </table>
    </div>





</div>
<!-- layui-tab开始 -->
</body>

<script src="__STATIC__/js/vue.js"></script>
<script src="__STATIC__/js/element/js/element.js"></script>

<include file="public/scripts"/>
<script>
    var app = new Vue({
        el: '#app',
        data: {

        },
        mounted() {
        },
        methods: {
            openAdd() {
                window.location.href = "{:cmf_plugin_url('ComMessage://admin_index/addPage')}";
            },
            openEdit(id) {
                window.location.href = "{:cmf_plugin_url('ComMessage://admin_index/editPage')}?id="+id;
            }
        }
    })

    $('.delete-btn').on('click',function(){
        var text = "确定要删除吗？";
        let id = $(this).data('id');
        let url = "{:cmf_plugin_url('ComMessage://admin_index/delEncy')}";
        layer.confirm(text, {icon: 3, title:'提示', btn: ['确定','取消']}, function(index,layero){
            $.ajax({
                url:url,
                data:{id:id},
                success:function(data){
                    if (data.code == 1) {
                        layer.msg(data.msg,{icon:1,time:1500},function(){
                            window.location.reload();
                        });
                    } else {
                        layer.msg(data.msg,{icon:2,time:1500});
                    }
                },
                error:function(){
                    layer.msg('系统错误',{icon:2,time:1500});
                }
            })
        },function(index){
            // alert('取消');
        });
    })


</script>
</html>